package com.zang.blogz.enmus;

import io.github.vampireachao.stream.core.optional.Sf;
import io.github.vampireachao.stream.core.stream.Steam;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

/**
* @author ZVerify
* @since 2022/11/21 10:35
**/
@AllArgsConstructor
@Getter
public enum ArticleTypeEnum {
    /**
     * 1原创
     */
    PUBLIC(1, "原创"),
    /**
     * 2转载
     */
    SECRET(2, "转载"),
    /**
     * 3翻译
     */
    DRAFT(3, "翻译");

    /**
     * 状态
     */
    private final Integer status;

    /**
     * 描述
     */
    private final String desc;

    /**
     * @param status 文章类型
     * @return {@link String} 所使用策略bean
     */
    public static String getMarkDownType(Integer status){

        return Sf.of(status).mayLet(s ->
                        Steam.of(ArticleTypeEnum.values())
                        .findFirst(v -> Objects.equals(v.getStatus(), status))
                        .orElse(PUBLIC)
                        .getDesc())
                .get();
    }
}
